<?php
namespace Product;

use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Product\Entity\Product;
use Product\Entity\Brand;
use Product\Entity\Category;
use Product\Model\ProductTable;
use Product\Model\BrandTable;
use Product\Model\CategoryTable;
class Module
{
    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }
    
    public function getServiceConfig()
    {
        return array(
            'factories' =>array(
                'Product\Model\Product' => function($sm){
                    $tableGateway = $sm->get('ProductTableGateway');
                    return new ProductTable($tableGateway);
                },
                'ProductTableGateway' => function($sm){
                    $adapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    //$resultSetPrototype->setArrayObjectPrototype(new Product());die(print 'ddd');
                    return new TableGateway('product' , $adapter , null , $resultSetPrototype);
                },
                
                'Product\Model\Brand' => function($sm){
                    $tableGateway = $sm->get('BrandTableGateway');
                    return new BrandTable($tableGateway);
                },    
                'BrandTableGateway' => function($sm){
                    $adapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    //$resultSetPrototype->setArrayObjectPrototype(new Brand());
                    return new TableGateway('brand' , $adapter , null , $resultSetPrototype);
                },
		'Product\Model\Category' => function($sm){
		    $tableGateway = $sm->get('CategoryTableGateway');
		    return new CategoryTable($tableGateway);
		},
		'CategoryTableGateway' => function($sm){
		    $adapter = $sm->get('Zend\Db\Adapter\Adapter');
		    $resultSetPrototype = new ResultSet();
		    //$resultSetPrototype->setArrayObjectPrototype(new Category());
		    return new TableGateway('category' , $adapter , null , $resultSetPrototype);
		},
            ),
        );
    }
}
